package com.heatup.apt.common.dao;

import com.heatup.apt.model.TSysDistrice;
import com.heatup.apt.model.TSysDistriceExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Component;

@Component
public interface TSysDistriceMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int countByExample(TSysDistriceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int deleteByExample(TSysDistriceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    @Delete({
        "delete from t_sys_districe",
        "where district_ID = #{districtId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long districtId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    @Insert({
        "insert into t_sys_districe (district_ID, district_name, ",
        "city_ID, date_created, ",
        "date_updated)",
        "values (#{districtId,jdbcType=BIGINT}, #{districtName,jdbcType=VARCHAR}, ",
        "#{cityId,jdbcType=BIGINT}, #{dateCreated,jdbcType=TIMESTAMP}, ",
        "#{dateUpdated,jdbcType=TIMESTAMP})"
    })
    int insert(TSysDistrice record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int insertSelective(TSysDistrice record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    List<TSysDistrice> selectByExampleWithRowbounds(TSysDistriceExample example, RowBounds rowBounds);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    List<TSysDistrice> selectByExample(TSysDistriceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "district_ID, district_name, city_ID, date_created, date_updated",
        "from t_sys_districe",
        "where district_ID = #{districtId,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    TSysDistrice selectByPrimaryKey(Long districtId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") TSysDistrice record, @Param("example") TSysDistriceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") TSysDistrice record, @Param("example") TSysDistriceExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(TSysDistrice record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_districe
     *
     * @mbggenerated
     */
    @Update({
        "update t_sys_districe",
        "set district_name = #{districtName,jdbcType=VARCHAR},",
          "city_ID = #{cityId,jdbcType=BIGINT},",
          "date_created = #{dateCreated,jdbcType=TIMESTAMP},",
          "date_updated = #{dateUpdated,jdbcType=TIMESTAMP}",
        "where district_ID = #{districtId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TSysDistrice record);


    /**
     * 查询所有区
     * @return
     */
    List<TSysDistrice> queryAllArea();

    /**
     * 查询区ID
     * @param area
     * @param cityId
     * @return
     */
    Long queryAreaIdByName(String area, Integer cityId);

    /**
     * 查询区名称
     * @param areaId 区ID
     * @return
     */
    String queryAreaNameById(String areaId);
}